home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / CHIP 2005-06.iso / program / e-is / OOo_2.0beta_tr_TR_WinIntel / openofficeorg2.cab / table_cells.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2005-03-16  |  15.7 KB  |  308 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.    $RCSfile: table_cells.xsl,v $
  5.  
  6.    $Revision: 1.3 $
  7.  
  8.    last change: $Author: rt $ $Date: 2004/07/05 09:06:30 $
  9.  
  10.    The Contents of this file are made available subject to the terms of
  11.    either of the following licenses
  12.  
  13.           - GNU Lesser General Public License Version 2.1
  14.           - Sun Industry Standards Source License Version 1.1
  15.  
  16.    Sun Microsystems Inc., October, 2000
  17.  
  18.    GNU Lesser General Public License Version 2.1
  19.    =============================================
  20.    Copyright 2000 by Sun Microsystems, Inc.
  21.    901 San Antonio Road, Palo Alto, CA 94303, USA
  22.  
  23.    This library is free software; you can redistribute it and/or
  24.    modify it under the terms of the GNU Lesser General Public
  25.    License version 2.1, as published by the Free Software Foundation.
  26.  
  27.    This library is distributed in the hope that it will be useful,
  28.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  29.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  30.    Lesser General Public License for more details.
  31.  
  32.    You should have received a copy of the GNU Lesser General Public
  33.    License along with this library; if not, write to the Free Software
  34.    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  35.    MA  02111-1307  USA
  36.  
  37.  
  38.    Sun Industry Standards Source License Version 1.1
  39.    =================================================
  40.    The contents of this file are subject to the Sun Industry Standards
  41.    Source License Version 1.1 (the "License"); You may not use this file
  42.    except in compliance with the License. You may obtain a copy of the
  43.    License at http://www.openoffice.org/license.html.
  44.  
  45.    Software provided under this License is provided on an "AS IS" basis,
  46.    WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING,
  47.    WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
  48.    MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
  49.    See the License for the specific provisions governing your rights and
  50.    obligations concerning the Software.
  51.  
  52.    The Initial Developer of the Original Code is: Sun Microsystems, Inc.
  53.  
  54.    Copyright ┬⌐ 2002 by Sun Microsystems, Inc.
  55.  
  56.    All Rights Reserved.
  57.  
  58.    Contributor(s): _______________________________________
  59.  
  60. -->
  61. <!--
  62.     For further documentation and updates visit http://xml.openoffice.org/sx2ml
  63. -->
  64. <xsl:stylesheet version="1.0"
  65.     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  66.     xmlns:office="http://openoffice.org/2000/office"
  67.     xmlns:style="http://openoffice.org/2000/style"
  68.     xmlns:text="http://openoffice.org/2000/text"
  69.     xmlns:table="http://openoffice.org/2000/table"
  70.     xmlns:draw="http://openoffice.org/2000/drawing"
  71.     xmlns:fo="http://www.w3.org/1999/XSL/Format"
  72.     xmlns:xlink="http://www.w3.org/1999/xlink"
  73.     xmlns:number="http://openoffice.org/2000/datastyle"
  74.     xmlns:svg="http://www.w3.org/2000/svg"
  75.     xmlns:chart="http://openoffice.org/2000/chart"
  76.     xmlns:dr3d="http://openoffice.org/2000/dr3d"
  77.     xmlns:math="http://www.w3.org/1998/Math/MathML"
  78.     xmlns:form="http://openoffice.org/2000/form"
  79.     xmlns:script="http://openoffice.org/2000/script"
  80.     xmlns:dc="http://purl.org/dc/elements/1.1/"
  81.     xmlns:meta="http://openoffice.org/2000/meta"
  82.     xmlns:config="http://openoffice.org/2001/config"
  83.     xmlns:help="http://openoffice.org/2000/help"
  84.     xmlns:xt="http://www.jclark.com/xt"
  85.     xmlns:common="http://exslt.org/common"
  86.     xmlns:xalan="http://xml.apache.org/xalan"
  87.     exclude-result-prefixes="office style text table draw fo xlink number svg chart dr3d math form script dc meta config help xt common xalan">
  88.  
  89.  
  90.     <!-- *********************************** -->
  91.     <!-- *** write repeating table cells *** -->
  92.     <!-- *********************************** -->
  93.  
  94.  
  95.     <!-- matching cells to give out -> covered table cells are not written out -->
  96.     <xsl:template match="table:table-cell">
  97.         <xsl:param name="globalData" />
  98.         <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  99.         <xsl:param name="allTableColumns" />
  100.         <xsl:param name="maxRowLength" />
  101.         <xsl:param name="tableDataType" />
  102.  
  103.  
  104.         <!-- The column position of the current cell has to be determined
  105.         to get the adequate column styles during later cell creation,
  106.         or hiding the cell when @table:visibility is not set to 'visible'.
  107.  
  108.         The position is archieved by adding up all table:number-columns-repeated of the preceding cells.
  109.             Step1: creating '$precedingCells/quantity/@table:number-columns-repeated').
  110.             Step2: sum(xxx:nodeset($precedingCells)/quantity) + 1        -->
  111.         <xsl:variable name="precedingCells">
  112.             <xsl:for-each select="preceding-sibling::*">
  113.                 <xsl:choose>
  114.                     <!-- maybe a parser is used, which reads the DTD files (e.g. Xerces),
  115.                         then '1' is the default for 'table:number-columns-repeated' -->
  116.                     <xsl:when test="not(@table:number-columns-repeated and @table:number-columns-repeated > 1)">
  117.                         <xsl:element name="quantity" namespace="">
  118.                             <xsl:text>1</xsl:text>
  119.                         </xsl:element>
  120.                     </xsl:when>
  121.                     <xsl:otherwise>
  122.                         <xsl:element name="quantity" namespace="">
  123.                             <xsl:value-of select="@table:number-columns-repeated" />
  124.                         </xsl:element>
  125.                     </xsl:otherwise>
  126.                 </xsl:choose>
  127.             </xsl:for-each>
  128.  
  129.             <!-- one column position added for itself -->
  130.             <xsl:element name="quantity" namespace="">
  131.                 <xsl:text>1</xsl:text>
  132.             </xsl:element>
  133.         </xsl:variable>
  134.  
  135.         <xsl:choose>
  136.             <xsl:when test="function-available('xt:node-set')">
  137.                 <xsl:call-template name="create-table-cell">
  138.                     <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  139.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  140.                     <xsl:with-param name="maxRowLength"     select="$maxRowLength" />
  141.                     <xsl:with-param name="columnPosition"   select="sum(xt:node-set($precedingCells)/*)" />
  142.                     <xsl:with-param name="globalData"       select="$globalData" />
  143.                     <xsl:with-param name="tableDataType"    select="$tableDataType" />
  144.                 </xsl:call-template>
  145.             </xsl:when>
  146.             <xsl:when test="function-available('common:nodeset')">
  147.                 <xsl:call-template name="create-table-cell">
  148.                     <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  149.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  150.                     <xsl:with-param name="maxRowLength"     select="$maxRowLength" />
  151.                     <xsl:with-param name="columnPosition"   select="sum(common:nodeset($precedingCells)/*)" />
  152.                     <xsl:with-param name="globalData"       select="$globalData" />
  153.                     <xsl:with-param name="tableDataType"    select="$tableDataType" />
  154.                 </xsl:call-template>
  155.             </xsl:when>
  156.             <xsl:when test="function-available('xalan:nodeset')">
  157.                 <xsl:call-template name="create-table-cell">
  158.                     <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  159.                     <xsl:with-param name="allTableColumns"  select="$allTableColumns" />
  160.                     <xsl:with-param name="maxRowLength"     select="$maxRowLength" />
  161.                     <xsl:with-param name="columnPosition"   select="sum(xalan:nodeset($precedingCells)/*)" />
  162.                     <xsl:with-param name="globalData"       select="$globalData" />
  163.                     <xsl:with-param name="tableDataType"    select="$tableDataType" />
  164.                 </xsl:call-template>
  165.             </xsl:when>
  166.             <xsl:otherwise>
  167.                 <xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>
  168.             </xsl:otherwise>
  169.         </xsl:choose>
  170.     </xsl:template>
  171.  
  172.  
  173.     <!-- current node is a table:table-cell -->
  174.     <xsl:template name="create-table-cell">
  175.         <!-- position of the current input cell to get the correct colum style (hidden are also counted)-->
  176.         <xsl:param name="allTableColumns" />
  177.         <xsl:param name="globalData" />
  178.         <xsl:param name="maxRowLength" />
  179.         <xsl:param name="columnPosition" />
  180.         <xsl:param name="tableDataType" />
  181.  
  182.         <xsl:if test="$debugEnabled">
  183.             <xsl:message>
  184.                 <xsl:text>
  185.                     table:table-cell #</xsl:text>
  186.                 <xsl:value-of select="$columnPosition" />
  187.                 <xsl:text> has been entered with node value: </xsl:text>
  188.                 <xsl:value-of select="." />
  189.                 <xsl:text>
  190.                     table:number-columns-repeated: </xsl:text>
  191.                 <xsl:value-of select="@table:number-columns-repeated" />
  192.                 <xsl:text>
  193.                     maxRowLength: </xsl:text>
  194.                 <xsl:value-of select="$maxRowLength" />
  195.             </xsl:message>
  196.         </xsl:if>
  197.  
  198.         <!-- only non hidden column will be given out -->
  199.         <xsl:variable name="currentTableColumn" select="$allTableColumns/table:table-column[position() = $columnPosition]" />
  200.         <xsl:if test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]">
  201.             <xsl:choose>
  202.                 <!-- if parser reads DTD the default is set to '1' -->
  203.                 <xsl:when test="@table:number-columns-repeated > 1">
  204.                     <!-- writes multiple entries of a cell -->
  205.                     <xsl:call-template name="repeat-write-cell">
  206.                         <xsl:with-param name="globalData"               select="$globalData" />
  207.                         <xsl:with-param name="allTableColumns"          select="$allTableColumns" />
  208.                         <xsl:with-param name="columnPosition"           select="$columnPosition" />
  209.                         <xsl:with-param name="currentTableColumn"       select="$currentTableColumn" />
  210.                         <xsl:with-param name="maxRowLength"             select="$maxRowLength" />
  211.                         <xsl:with-param name="numberColumnsRepeated"    select="@table:number-columns-repeated" />
  212.                         <xsl:with-param name="tableDataType"            select="$tableDataType" />
  213.                     </xsl:call-template>
  214.                 </xsl:when>
  215.                 <xsl:otherwise>
  216.                     <!-- writes an entry of a cell -->
  217.                     <xsl:call-template name="write-cell">
  218.                         <xsl:with-param name="globalData"           select="$globalData" />
  219.                         <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  220.                         <xsl:with-param name="columnPosition"       select="$columnPosition" />
  221.                         <xsl:with-param name="currentTableColumn"   select="$currentTableColumn" />
  222.                         <xsl:with-param name="maxRowLength"         select="$maxRowLength" />
  223.                         <xsl:with-param name="tableDataType"        select="$tableDataType" />
  224.                     </xsl:call-template>
  225.                 </xsl:otherwise>
  226.             </xsl:choose>
  227.         </xsl:if>
  228.     </xsl:template>
  229.  
  230.  
  231.     <xsl:template name="repeat-write-cell">
  232.         <xsl:param name="globalData" />
  233.         <xsl:param name="allTableColumns" />
  234.         <xsl:param name="columnPosition" />
  235.         <xsl:param name="currentTableColumn" />
  236.         <xsl:param name="maxRowLength" />
  237.         <xsl:param name="numberColumnsRepeated" />
  238.         <xsl:param name="tableDataType" />
  239.  
  240.         <xsl:choose>
  241.             <!-- This is the current workaround for the flood of cells, simulation background by repeating cell -->
  242.             <xsl:when test="$numberColumnsRepeated > 1 and $maxRowLength > $columnPosition">
  243.  
  244.                 <!-- writes an entry of a cell -->
  245.                 <xsl:call-template name="write-cell">
  246.                     <xsl:with-param name="globalData"           select="$globalData" />
  247.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  248.                     <xsl:with-param name="columnPosition"       select="$columnPosition" />
  249.                     <xsl:with-param name="currentTableColumn"   select="$currentTableColumn" />
  250.                     <xsl:with-param name="tableDataType"        select="$tableDataType" />
  251.                 </xsl:call-template>
  252.                 <!-- repeat calling this method until all elements written out -->
  253.                 <xsl:if test="$debugEnabled">
  254.                     <xsl:message>+++++++++ cell repetition +++++++++</xsl:message>
  255.                 </xsl:if>
  256.                 <xsl:call-template name="repeat-write-cell">
  257.                     <xsl:with-param name="globalData"               select="$globalData" />
  258.                     <xsl:with-param name="allTableColumns"          select="$allTableColumns" />
  259.                     <xsl:with-param name="columnPosition"           select="$columnPosition + 1" />
  260.                     <xsl:with-param name="currentTableColumn"       select="$allTableColumns/table:table-column[position() = ($columnPosition + 1)]" />
  261.                     <xsl:with-param name="maxRowLength"             select="$maxRowLength" />
  262.                     <xsl:with-param name="numberColumnsRepeated"    select="$numberColumnsRepeated - 1" />
  263.                     <xsl:with-param name="tableDataType"            select="$tableDataType" />
  264.                 </xsl:call-template>
  265.             </xsl:when>
  266.             <xsl:otherwise>
  267.                 <!-- This is the current workaround for the flood of cells, simulation background by repeating cell -->
  268.                 <!--      When the maxRowLength is reached a last entry of a cell is written -->
  269.                 <xsl:call-template name="write-cell">
  270.                     <xsl:with-param name="globalData"           select="$globalData" />
  271.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  272.                     <xsl:with-param name="columnPosition"       select="$columnPosition" />
  273.                     <xsl:with-param name="currentTableColumn"   select="$currentTableColumn" />
  274.                     <xsl:with-param name="tableDataType"        select="$tableDataType" />
  275.                 </xsl:call-template>
  276.             </xsl:otherwise>
  277.         </xsl:choose>
  278.     </xsl:template>
  279.  
  280.  
  281.     <xsl:template name="write-cell">
  282.         <xsl:param name="globalData" />
  283.         <xsl:param name="allTableColumns" />
  284.         <xsl:param name="columnPosition" />
  285.         <xsl:param name="currentTableColumn" />
  286.         <xsl:param name="tableDataType" />
  287.  
  288.         <!-- a non hidden column will be give out -->
  289.         <xsl:choose>
  290.             <xsl:when test="$currentTableColumn[not(@table:visibility = 'collapse' or @table:visibility = 'filter')]">
  291.                 <xsl:call-template name="create-table-cell-content">
  292.                     <xsl:with-param name="globalData"           select="$globalData" />
  293.                     <xsl:with-param name="allTableColumns"      select="$allTableColumns" />
  294.                     <xsl:with-param name="columnPosition"       select="$columnPosition" />
  295.                     <xsl:with-param name="currentTableColumn"   select="$currentTableColumn" />
  296.                     <xsl:with-param name="tableDataType"        select="$tableDataType" />
  297.                 </xsl:call-template>
  298.             </xsl:when>
  299.             <!-- a hidden column -->
  300.             <xsl:otherwise>
  301.                 <xsl:if test="$debugEnabled">
  302.                     <xsl:message>table column is hidden!</xsl:message>
  303.                 </xsl:if>
  304.             </xsl:otherwise>
  305.         </xsl:choose>
  306.     </xsl:template>
  307. </xsl:stylesheet>
  308.